<template>
  <div id="app">

    <mt-header v-if="navbar.status">

      <span slot="username">你好, {{user.name}}</span>

    </mt-header>

    <el-container v-if="navbar.status">

      <el-container>
        <el-main>
          <transition name="el-fade-in">
            <!-- <keep-alive> -->
              <router-view/>
            <!-- </keep-alive> -->
          </transition>
        </el-main>
      </el-container>
      <el-footer>@copyright by maotu</el-footer>
    </el-container>



    <router-view v-if="!navbar.status"/>

  </div>
</template>

<script>
  import mtHeader from '@/components/common/Header'
  import {mapGetters , mapMutations} from 'vuex'
  import Cookies from 'js-cookie'

  import * as User from '@/api/users'

  export default {
      name: 'app',
      computed: {
        ...mapGetters([
          'navbar'
          // ...
        ])
      },
    data() {
      return {
        user: {}
      }
    },
      components: {
        mtHeader,

      },

    mounted() {

      this.initApp();

    },
    methods: {

      initApp() {
        User.reg().then((user) => {
          this.user = user
        }).catch(() => {
          this.$message({
            message: '用户信息获取失败',
            type: "error"
          })
        });

      }

    }
  }


</script>
<style lang="sass">
  @import "./assets/style/main.sass"
</style>
